package com.mfnote.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
/**
 * 背景图片适配器
 * @author ZHF
 */
public class BgImageAdaper extends BaseAdapter{
	
	private Context context;
	private int[] bgImages;
	
	public BgImageAdaper(Context context, int[] bgImages) {
		this.context = context;
		this.bgImages = bgImages;
	}

	@Override
	public int getCount() {  //返回position
//		return images.length;
		return Integer.MAX_VALUE;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		ImageView iv= new ImageView(context);
//		iv.setImageResource(images[position]);
		iv.setImageResource(bgImages[position%bgImages.length]);  //循环
		
		iv.setAdjustViewBounds(true); //图片大小适应视图
		iv.setLayoutParams(new Gallery.LayoutParams(180,280)); //设置图片的宽高为Gallery.LayoutParams  因为Gallery时ViewGroup的子类哦
		iv.setPadding(30, 10, 30, 10);
		
		return iv;
	}

}
